package cn.edu.jxau.core.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * Desc:
 * ------------------------------------
 * Author:fulei04@meituan.com
 * Date:2017/12/17
 * Time:下午3:18
 */
public class CodecUtils {

    private static final String ENCODING = "UTF-8";

    public static String encodeURL(String url) {
        try {
            return URLEncoder.encode(url,ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("编码失败",e);
        }
    }

    public static String decodeURL(String url) {

        try {
            return URLDecoder.decode(url,ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("解码失败",e);
        }
    }
}
